<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require_once (APPPATH . "third_party/menu.php");

class Session_controller extends CI_Controller{
	
	protected $data;
	
	public function __construct() {
		parent::__construct();
		$session_data = $this->session->userdata('logged_in');
		if(!$session_data){
			redirect('login', 'refresh');
		}else{
			$this->load->model('jugador');
			$this->data['jugador'] = $this->jugador->id($session_data['id']);
			$this->data['titulo'] = "sin titulo";
			$this->data['css'] = array();
			$this->data['js'] = array();
/*			$menu = new Menu("Menú");
			$menu_cuenta = new Menu("Cuenta");
			$menu_cuenta->agregar(new Comando("Ver Perfil", "profile"));
			$menu_cuenta->agregar(new Comando("Editar Perfil", "profile/edit"));
			$menu_cuenta->agregar(new Comando("Borrar Cuenta", "profile/delete"));
			$menu_cuenta->agregar(new Separador());
			$menu_cuenta->agregar(new Comando("Salir", "home/logout"));
			$menu->agregar($menu_cuenta);
			$menu_picon = new Menu("Picón");
			$menu_picon->agregar(new Comando("Crear","#"));
			$menu_picon->agregar(new Comando("Próximos Picones", "#"));
			$menu_picon->agregar(new Comando("Picones Terminados", "#"));
			$menu->agregar($menu_picon);
*/			
			
			if(strcmp($this->data['jugador']->rol, "admin") == 0){
				$this->data['menu'] = 'componentes/menu_admin';
			}else{
				$this->data['menu'] = 'componentes/menu_user';
			}
		}
	}
	public function add_css($hoja){
		$this->data['css'][] = '<link rel="stylesheet" type="text/css" href="'. $hoja .'"/>';
	}
	public function add_js($script){
		$this->data['js'][] = '<script src="' . $script .'"></script>';
	}
	public function show($content){
		$this->data['content'] = $content;
		$this->load->view('template', $this->data);
	}
}
